import QtQuick 2.6


PopupFrame {
    id: view
    width: iWIDTH * 32

    height: Math.min(iHEIGHT * 8, shadow.height * 0.7)

    property alias model: listview.model
    property string textRole: ""

    property var callback: null

    ListView {
        id: listview
        anchors.fill: parent
        clip: true

        delegate:Rectangle{
            width: listview.width
            height: 96 * fx.factor
            Text {
                text: Array.isArray(listview.model) ?  modelData[textRole] : model[textRole]
                anchors.centerIn: parent
                font.pointSize: 11 * fx.radio
            }

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    if (callback)
                        callback(Array.isArray(listview.model) ? modelData : model)
                    view.destroy()
                }
            }

            Rectangle {
                anchors.bottom: parent.bottom
                width: parent.width
                height: 1
                color: "gray"
            }

        }

    }

}
